<?php echo $this->Form->create('Variant', array('id' => 'VariantForm')); ?>
	<?php echo $this->Form->input('id') ?>
	<table class="form-table">
		<?php if(!isset($this->request->data['Variant']['id'])){?>
			<?php foreach($prototype['OptionType'] as $i => $option){ ?>
			<tr> 
				<td class='l-style'><?php echo $option['name'] ?></td>
				<td class="r-style width_middle">
					<?php $values = $this->OptionValues->getByOptionTypeId($option['id'])?>
					<?php echo $this->Form->input('OptionValue.OptionValue.' . $i, array('label' => false, 'type' => 'select', 'options' => $values)) ?>
				</td>
			</tr>
			<?php } ?>
		<?php } else { #edit mode ?>
			<?php foreach($this->request->data['OptionValue'] as $value) { ?>
			<tr> 
				<td class='l-style'>
					<?php $optionType = $this->OptionValues->findById($value['id']) ?>
					<?php echo $optionType['OptionType']['name'] ?>
				</td>
				<td class="r-style width_small">
					<input type="text" readonly value="<?php echo $value['name'] ?>" />
				</td>
			</tr>
			<?php } ?>
		<?php } ?>
		<tr>
			<td class='l-style'><?php echo __('Raw Price') ?></td>
			<td class="r-style width_middle"><?php echo $this->Form->input('raw_price', array('label' => false, 'class' => 'required digits')); ?></td>
		</tr>
		<tr>
			<td class='l-style'><?php echo __('Price') ?></td>
			<td class="r-style width_middle"><?php echo $this->Form->input('price', array('label' => false, 'class' => 'required digits')); ?></td>
		</tr>
		<tr>
			<td class='l-style'><?php echo __('Hand on') ?></td>
			<td class="r-style width_middle"><?php echo $this->Form->input('hand_on', array('label' => false, 'class' => 'required digits')); ?></td>
		</tr>
		<tr>
			<td class='l-style no-border no-background'>
				(<span class='red-star'>*</span>) <?php echo __('Required') ?>
			</td>
			<td class="r-style actions no-border no-background"  style="line-height: 35px;">
				<?php echo $this->Form->submit(__('Submit'), array('id' => 'submit_post', 'class' => 'submit-more')); ?>
				<span>or&nbsp;&nbsp;<a href="#" id="remove-variant-form" class="act-lk remove-link"><?php echo __('Cancel') ?></a></span>
			</td>
		</tr>
	</table>
<?php echo $this->Form->end(); ?>

<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery("#remove-variant-form").click(function(){
			jQuery("#wrapper-form").hide();
			jQuery("#wrapper-form").html('');
		});

		jQuery("#VariantForm").validate();
	});
</script>
